package com.jxdinfo.hussar.example.scada.schedulingtask;

import com.alibaba.fastjson.JSON;
import com.jxdinfo.hussar.example.common.core.redis.RedisCache;
import com.jxdinfo.hussar.example.common.websocket.WebSocketUsers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class RedisToFrontTask {

    @Autowired
    private RedisCache redisCache;

//    @Scheduled(cron = "0/2 * * * * ?")
//    public void AccessToRedisTask() throws Exception {
//        queryMaterialData();
//    }

    public void queryMaterialData() throws Exception{
        //将得到的消息websocket传给前端
        WebSocketUsers.sendMessageToUsersByText(JSON.toJSONString(redisCache.getCacheList("Access")));
    }
}
